package test00.test05.t03;

import test00.test05.t01.Student;

import java.util.function.Consumer;

/**
 * @Author lzp
 * @Date 2024-04-11
 */
public class test {
    public static void main(String[] args) {

        Student[] stu ={
                new Student("张三三",17),
                new Student("李四四",18),
                new Student("王五",30)
        };

        Consumer<Student[]> consumer1 = (stuList) -> {
            //姓李的
            for (Student student : stuList) {
                if (student.getName().startsWith("李")){
                    System.out.println(student);
                }
            }
        };
        Consumer<Student[]> consumer2 = (stuList) -> {
            //三个字名字
            for (Student student : stuList) {
                if (student.getName().length() > 3){
                    System.out.println(student);
                }
            }
        };
        Consumer<Student[]> consumer3 = (stuList) -> {
            //年龄大于18
            for (Student student : stuList) {
                if (student.getAge() > 18){
                    System.out.println(student);
                }
            }
        };


        //andThen() - 串联多个Consumer
        consumer1.andThen(consumer2).andThen(consumer3);


    }
}
